package com.inspur.his.service.impl;

import com.inspur.his.mapper.MakeRegisterOrderMapper;
import com.inspur.his.pojo.MakeRegisterOrder;
import com.inspur.his.service.MakeRegisterOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class MakeRegisterOrderServiceImpl implements MakeRegisterOrderService {

    @Autowired
    private MakeRegisterOrderMapper makeRegisterOrderMapper;

    @Override
    public void addMakeRegister(MakeRegisterOrder makeRegisterOrder) {
        makeRegisterOrder.setOpTime(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
        makeRegisterOrderMapper.addMakeRegister(makeRegisterOrder);
    }

    @Override
    public List<MakeRegisterOrder> showMakeRegister(String departName, String doctorName, Integer roId, int currPage, int pageSize) {
        HashMap map = new HashMap<>();
        int startNum = (currPage - 1) * pageSize;
        map.put("startNum", startNum);
        map.put("pageSize", pageSize);
        map.put("departName", departName);
        map.put("doctorName", doctorName);
        map.put("roId", roId);
        return makeRegisterOrderMapper.showMakeRegister(map);
    }

    @Override
    public int count(String departName, String doctorName, Integer roId) {
        HashMap map = new HashMap<>();
        map.put("departName", departName);
        map.put("doctorName", doctorName);
        map.put("roId", roId);
        return makeRegisterOrderMapper.count(map);
    }

    @Override
    public void delete(Integer roId) {
        makeRegisterOrderMapper.delete(roId);
    }

    @Override
    public void update(MakeRegisterOrder makeRegisterOrder) {
        makeRegisterOrder.setOpTime(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
        makeRegisterOrderMapper.update(makeRegisterOrder);
    }

    @Override
    public MakeRegisterOrder getOneById(Integer roId) {
        return makeRegisterOrderMapper.getOneById(roId);
    }
}
